# SuperFastPython.com
# example of issuing a task with apply() with arguments to the process pool
from time import sleep
from multiprocessing.pool import Pool
 
# task executed in a worker process
def task(data):
    # report a message
    print(f'Task executing: {data}', flush=True)
    # block for a moment
    sleep(1)
    # report a message
    print(f'Task done: {data}', flush=True)
 
# protect the entry point
if __name__ == '__main__':
    # create and configure the process pool
    pool = Pool()
    # issue tasks to the process pool
    pool.apply(task, args=('Hello World',))
    # close the process pool
    pool.close()